package Operation;

import Book.BookList;

import java.util.Scanner;

public class FindOperation implements ioperation{
    public void work(BookList bookList) {
        System.out.println("查找图书！");

        //输入查找书的名字
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你要查找的书：");
        String name = scanner.nextLine();

        //遍历书架查找
        for (int i = 0; i < bookList.getUsedSize(); i++) {
            if(name.equals(bookList.getBooks(i).getName())){
                //找到了打印出书的信息并且退出
                System.out.println("找到了《"+name+"》");
                return;
            }


        }
        //遍历书架未找到该书
        System.out.println("没找到《"+name+"》");
    }
}
